package top.techqi.hamtools.db.model

import com.raizlabs.android.dbflow.annotation.Column
import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import com.raizlabs.android.dbflow.structure.BaseModel
import top.techqi.hamtools.db.HammerDB
import top.techqi.hamtools.db.assist.FreqUnit
import top.techqi.hamtools.db.assist.RstR
import top.techqi.hamtools.db.assist.RstS
import top.techqi.hamtools.db.assist.RstT
import top.techqi.hamtools.db.convert.FreqUnitConverter
import top.techqi.hamtools.db.convert.RstRConverter
import top.techqi.hamtools.db.convert.RstSConverter
import top.techqi.hamtools.db.convert.RstTConverter
import java.util.*

@Table(database = HammerDB::class, name = DiaryModel.NAME)
class DiaryModel : BaseModel() {
    @PrimaryKey(autoincrement = true)
    var id: Long = 0

    @Column(defaultValue = "?????")
    var sign: String = ""

    @Column(defaultValue = "")
    var mode: String = ""

    @Column
    var freq: Float = 0F

    @Column(defaultValue = "0", typeConverter = FreqUnitConverter::class)
    var freqUnit: FreqUnit = FreqUnit.Hz

    @Column
    var power: Float = 0F

    @Column
    var datetime: Date? = null

    @Column(defaultValue = "5", typeConverter = RstRConverter::class)
    var lctR = RstR.PERFECTLY

    @Column(defaultValue = "9", typeConverter = RstSConverter::class)
    var lctS = RstS.EXTREMELY

    @Column(defaultValue = "0", typeConverter = RstTConverter::class)
    var lctT = RstT.UNKNOWN

    @Column(defaultValue = "5", typeConverter = RstRConverter::class)
    var rmtR = RstR.PERFECTLY

    @Column(defaultValue = "9", typeConverter = RstSConverter::class)
    var rmtS = RstS.EXTREMELY

    @Column(defaultValue = "0", typeConverter = RstTConverter::class)
    var rmtT = RstT.UNKNOWN

    @Column(defaultValue = "")
    var locate: String = ""

    @Column(defaultValue = "")
    var remote: String = ""

    @Column(defaultValue = "")
    var note: String = ""

    companion object {
        const val NAME = "diary"
    }
}
